<?php
/**
 * 权限数据模型
 * @author Administrator
 *
 */
class jurSellpointModel extends MY_Model{
    function jurSellpointModel(){
        parent::MY_Model();
        $this->table = 'js_jurisdiction_sellpoint';
    }
    /**
     * 覆盖父类方法
     * @see MY_Model::getData()
     */
    function getData($where = '', $colum =''){
        //更改数据库链接配置
        $this->db = $this->load->database('ntsdf', true);
        $findData = parent::getData($where, $colum);
        //查完之后将数据库链接设置回默认设置
        $this->db = $this->load->database('', true);
        return $findData;
    }
    /**
     * 覆盖父类方法(non-PHPdoc)
     * @see MY_Model::getList()
     */
    function getList($where = '', $limit = NULL, $offset = NULL, $colum = '', $orderby = ''){
        //更改数据库链接配置
        $this->db = $this->load->database('ntsdf', true);
        $findList = parent::getList($where, $limit, $offset, $colum, $orderby);
        //查完之后将数据库链接设置回默认设置
        $this->db = $this->load->database('', true);
        return $findList;
    }
    /**
     * 获取城市联合对应城市主担店ID集
     * @param  string $city 城市名称
     * @return array
     */
    function getMainStoreId($city){
        $baichengIds = $this->get100CityStoreIds();
        //查询自己所在城市主担店的专营店ID
        $this->CI->load->model('sellpointModel');
        $mainStoreList = $this->CI->sellpointModel->getList(array('County'=>utf82gbk($city), 'SellPointID'=>array('in',$baichengIds) ));
        $mainStoreIds = array();
        foreach ($mainStoreList as $key => $value) {
            $mainStoreIds[] = (int)$value['SellPointID'];
        }
        return $mainStoreIds;
    }
    /**
     * 获取百城主单店ID集
     */
    function get100CityStoreIds(){
        //百城主担店列表
        $findList = $this->getList(array('application_system_id'=>61,'jurisdiction_id'=>117));
        $baichengIds = array();
        foreach ($findList as $key => $value) {
            $baichengIds[] = (int)$value['SellPointID'];
        }
        return $baichengIds;
    }
}